package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.diboot.core.util.BeanUtils;
import com.example.demo.entity.ProductionOrder;
import com.example.demo.mapper.ProductionOrderMapper;
import com.example.demo.service.ProductionOrderService;
import com.example.demo.service.impl.BaseCustomServiceImpl;
import com.example.demo.vo.ProductionOrderDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.io.Serializable;

/**
* 生产单相关Service实现
* @author MyName
* @version 1.0
* @date 2024-02-26
 * Copyright © MyCompany
*/
@Service
@Slf4j
public class ProductionOrderServiceImpl extends BaseCustomServiceImpl<ProductionOrderMapper, ProductionOrder> implements ProductionOrderService {

    @Override
    public List<ProductionOrderDetailVO> getProductionOrderTree(Serializable rootId) {
        LambdaQueryWrapper<ProductionOrder> queryWrapper = new LambdaQueryWrapper<ProductionOrder>();
        queryWrapper.orderByAsc(ProductionOrder::getId);
        List<ProductionOrder> productionOrderList = getEntityList(queryWrapper);
        List<ProductionOrderDetailVO> productionOrderDetailVOList = BeanUtils.convertList(productionOrderList, ProductionOrderDetailVO.class);
        return BeanUtils.buildTree(productionOrderDetailVOList, rootId);
    }

}
